﻿<%@ include file="../include/top.jsp"%>
<%@ include file="../include/errorArea.jsp" %>

<link rel="stylesheet" href="${baseURL}/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script language="javascript" type="text/javascript" src="${baseURL}/js/jquery.ztree.all-3.5.min.js">
</script>
<SCRIPT type="text/javascript">
	var setting = {
		view: {
			dblClickExpand: false
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onClick: onClick
		}
	};

	var zNodes = ${treedata}; //后台返回的数据

	function onClick(e,treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("treeDemo");
		zTree.expandNode(treeNode);

		//叶节点，并且不是第一层节点(第一层节点的pId是null)
		//if(!treeNode.isParent && treeNode.pId!=null){
			nodes = zTree.getSelectedNodes();
			$("#selectedNodeName").attr("value", treeNode.name);
			$("#nodeId").attr("value", treeNode.id);
		//}
	}

	function showMenu() {
		var cityObj = $("#selectedNodeName");
		var cityOffset = $("#selectedNodeName").offset();
		$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

		$("body").bind("mousedown", onBodyDown);
	}
	function hideMenu() {
		$("#menuContent").fadeOut("fast");
		$("body").unbind("mousedown", onBodyDown);
	}
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "selectedNodeName" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}

	$(document).ready(function(){
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		
		var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
		var nodes = treeObj.getNodesByParam("id", "${formdata.nodeId}", null);
		if (nodes.length>0) {
			treeObj.selectNode(nodes[0]);
		}

	});
	function createProductPlace(){
		var str="";
		var checkArray = document.getElementsByName("chk");
		for (var i = 0; i < checkArray.length; i++) {
			if(checkArray[i].checked){
				str += checkArray[i].value + ",";
			}
		}
		
		var dot = str.substr(0,str.length-1);
		if(dot==0){
			alert("请选择要添加产地信息的商品。");
			return;
		}else{
			$.layer({
			    type: 2,
			    maxmin: true,
			    shadeClose: true,
			    title: '添加商品产地信息',
			    shade: [0.1,'#fff'],
			    offset: [($(window).height() / 10)+'px',''],
			    area: ['300px', '150px'],
			    iframe: {src: '${ctx}/supplierProduct/preCdxxCreate/'+dot}
			});
		}
	}
	function clickSS(){
		document.getElementById("Image8").click(); 
		$("#Image8").click();
	}
	
	function orderByColumn(column){
		var orderByType = $("#orderByType").val();
		if(orderByType == '' || orderByType == null){
			$("#orderByType").val("asc");
		}else if(orderByType == 'asc'){
			$("#orderByType").val("desc");
		}else{
			$("#orderByType").val("asc");
		}
		$("#columnInput").val(column);
		$('#searchForm').attr("action","${ctx}/supplierProduct/listProduct?upStatus=0");
		$("#searchForm").submit();
	}
</SCRIPT>
<form action="" method="get" name="searchForm" id="searchForm">
<input type="hidden" name="p" value="1" />
<input type="hidden" id="columnInput" name="columnInput" value="${columnInput}"/>
<input type="hidden" id="orderByType" name="orderByType" value="${orderByType}"/>
<div class='adduser'>
	<div class='adduser-left'><div class='adduser-icon'></div><span>商品管理</span></div>
</div>
<div class='querycondition'>
	<div class='condtiontitle'><div class='searchcondition'></div>搜索条件：</div>
	<div class='condtion'>
	  		商品编号：<input name="productCode" type="text" id="productCode" value="${formdata.productCode}" size="10"/>    
	      	商品名称：<input name="keyword" type="text" id="keyword" value="${formdata.keyword}" size="20"/>
			所属分类：
				<input type="hidden" name="nodeId" id="nodeId" value="${formdata.nodeId}"/>
			<input name="selectedNodeName" id="selectedNodeName" type="text" readonly value="${formdata.selectedNodeName}" size="40" onclick="showMenu()"/>
			<div id="menuContent" class="menuContent" style="display:none; position: absolute;">
				<ul id="treeDemo" class="ztree" style="margin-top:0; width:300px;"></ul>
			</div><br/>
	  		审核状态：
	  		<select id="passStatus" name="passStatus" style="width:100px">
				<option value="">全部</option>
				<option value="0" ${formdata.passStatus=="0"?"selected":""}>未审核</option>
				<option value="1" ${formdata.passStatus=="1"?"selected":""}>审核通过</option>
			<option value="2" ${formdata.passStatus=="2"?"selected":""}>审核未通过</option>
			</select>&nbsp;&nbsp;&nbsp; 
			上架状态：
	  		<select id="upStatus" name="upStatus" style="width:100px">
				<option value="">全部</option>
				<option value="0" ${formdata.upStatus=="0"?"selected":""}>上架</option>
				<option value="1" ${formdata.upStatus=="1"?"selected":""}>下架</option>
			</select>&nbsp;&nbsp;&nbsp; 
			预定状态：
	  		<select id="reserveFlag" name="reserveFlag" style="width:100px">
				<option value="">全部</option>
				<option value="0" ${formdata.reserveFlag=="0"?"selected":""}>非预定商品</option>
				<option value="1" ${formdata.reserveFlag=="1"?"selected":""}>预订商品</option>
			</select>&nbsp;&nbsp;&nbsp; 
			商品类型：
	  		<select id="virtualFlag" name="virtualFlag" style="width:100px">
				<option value="">全部</option>
				<option value="0" ${formdata.virtualFlag=="0"?"selected":""}>实物</option>
				<option value="1" ${formdata.virtualFlag=="1"?"selected":""}>非实物</option>
			</select>&nbsp;&nbsp;&nbsp; 
	</div>
</div>
<div class='querycondition'>
	<div class='condtion'>
		<input name="image" style="display:none" type="image" id="Image8" onmouseover="MM_swapImage('Image8','','${baseURL}/images/button_ss_a.jpg',1)" onmouseout="MM_swapImgRestore()" src="${baseURL}/images/button_ss.jpg"/>
	    <%-- <img src="${baseURL}/images/button_qk.jpg" name="clearButton" id="clearButton" style="cursor:pointer" onclick="clearInput()" onmouseover="MM_swapImage('clearButton','','${baseURL}/images/button_qk_a.jpg',1)" onmouseout="MM_swapImgRestore()"/>  --%>
		
		<input type='button' value='搜索'  class='button cyan medium' onclick="clickSS();">&nbsp;&nbsp;
		<input type='button' value='清空' class='button cyan medium' onclick="clearInput()">	
		
		<img src="${baseURL}/images/bit_01.png" width="16" height="14" border="0" align="absmiddle" />
		  	&nbsp;<a href="#" class="a2_blue" onclick="window.location = 'toAddProduct';">添加商品</a>&nbsp;&nbsp;&nbsp;&nbsp;
		<img src="${baseURL}/images/bit_01.png" width="16" height="14" border="0" align="absmiddle" />
		  	&nbsp;<a href="#" class="a2_blue" onclick="createProductPlace();">添加商品产地信息</a>&nbsp;&nbsp;&nbsp;&nbsp;
	</div>
</div>
</form>
<%-- <table>
	<tr>
		<td> 
			<input name="image" type="image" id="Image8" onmouseover="MM_swapImage('Image8','','${baseURL}/images/button_ss_a.jpg',1)" onmouseout="MM_swapImgRestore()" src="${baseURL}/images/button_ss.jpg"/>
		    <img src="${baseURL}/images/button_qk.jpg" name="clearButton" id="clearButton" style="cursor:pointer" onclick="clearInput()" onmouseover="MM_swapImage('clearButton','','${baseURL}/images/button_qk_a.jpg',1)" onmouseout="MM_swapImgRestore()"/> 
		
			<img src="${baseURL}/images/bit_01.png" width="16" height="14" border="0" align="absmiddle" />
			  	&nbsp;<a href="#" class="a2_blue" onclick="window.location = 'toAddProduct';">添加商品</a>&nbsp;&nbsp;&nbsp;&nbsp;
			<img src="${baseURL}/images/bit_01.png" width="16" height="14" border="0" align="absmiddle" />
			  	&nbsp;<a href="#" class="a2_blue" onclick="createProductPlace();">添加商品产地信息</a>&nbsp;&nbsp;&nbsp;&nbsp;
		</td>
	</tr>
</table> --%>


<c:if test="${empty obj.list}">
<div align="center"><b>没有符合条件的记录。</b></div>
</c:if>
<c:if test="${not empty obj.list}">
	<div class='userlist-title'>
		<div class='userlist-title-left'><div class='userlist-title-icon'></div><span>商品列表</span></div>
	</div>
	<div class='userlist'>
	<table cellpadding=0 cellspacing=0 id="listTable">
		<tr class='userlist-tr-title'>
			<td height="25" width="3%" class='userlist-td operation'><input type="checkbox" onclick="selectAll(this.checked);"></td>
			<td class='userlist-td' width="8%"><a href="javascript:;" onclick="orderByColumn('productCode')">商品编号</a></td>
			<td class='userlist-td' width="12%"><a href="javascript:;" onclick="orderByColumn('productName')">商品名称</a></td>
			<td class='userlist-td' width="5%"><a href="javascript:;" onclick="orderByColumn('supplierPrice')">供货价</a></td>
			<td class='userlist-td' width="5%">库存数量</td>
			<td class='userlist-td' width="5%"><a href="javascript:;" onclick="orderByColumn('sellNumber')">销售数量</a></td>
			<td class='userlist-td' width="12%">产地信息</td>
			<td class='userlist-td' width="8%">审核状态</td>
			<td class='userlist-td' width="20%">审核意见</td>
			<td class='userlist-td userlist-td-r'>操作</td>
		</tr>
	<c:forEach var="oneRow" items="${obj.list}">
		<tr>
			<td class='userlist-td'><input name="chk" type="checkbox" id="chk" value="${oneRow.id}" /></td>
			<td class='userlist-td'>${oneRow.productCode}</td>
			<td class='userlist-td' style="text-align:left;">${oneRow.productName}</td>
			<td class='userlist-td' style="text-align:right;">${oneRow.supplierPrice}</td>
			<td class='userlist-td' style="text-align:right;">${oneRow.stockNumber}</td>
			<td class='userlist-td' style="text-align:right;">${oneRow.sellNumber}</td>
			<td class='userlist-td' style="text-align:left;">${oneRow.productPlace}</td>
			<td class='userlist-td'><c:if test="${oneRow.passStatus==1}"><font color="#339241">审核通过</font></c:if>
				<c:if test="${oneRow.passStatus==0}"><font color="black">未审核</font></c:if>
				<c:if test="${oneRow.passStatus==2}"><font color="red">审核未通过</font></c:if></td>
			<td class='userlist-td'>${oneRow.checkResult}</td>
			<td class='userlist-td userlist-td-r'>
			<a href="toEditProduct?id=${oneRow.id}">[编辑]</a>
				<c:if test="${oneRow.upStatus==0}"><a href="#" onclick="upById('${ctx}',${oneRow.id},'1')">[下架]</a></c:if>
					<c:if test="${oneRow.upStatus==1}"><a href="#" onclick="upById('${ctx}',${oneRow.id},'0')">[上架]</a></c:if>
			<a href="#" onclick="delById('${ctx}',${oneRow.id})">[删除]</a>
			</td>
		</tr>
	</c:forEach>
	  
	</table>
	<table>
		<tr>
			<td height="5" colspan="2">
	   		<input name="button" type="button" onclick="delByIds('${ctx}');" value="批量删除" class='button cyan medium'></td>
		  </tr>
		  <tr>
		    <td align="right" height="25" colspan="1"><%@ include file="../include/listpage.jsp"%>
		    </td>
		  </tr>
	</table>
	<script src="${ctx}/js/listSupplierProduct.js"></script>
	</div>
</c:if>
<script>
$("#supplierId").val("${formdata.supplierId}");

function clearInput() {
	document.getElementById("passStatus").options[0].selected=true;
	document.getElementById("productCode").value = "";
	document.getElementById("keyword").value = "";
	document.getElementById("nodeId").value = "";
	document.getElementById("selectedNodeName").value = "";
	document.getElementById("supplierId").options[0].selected=true;
}

function selectAll(checkAllFlag) {
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		checkArray[i].checked = checkAllFlag;
	}
}
</script>
<%-- <c:if test="${empty obj.list}">
<div align="center"><b>没有符合条件的记录。</b></div>
</c:if>
<c:if test="${not empty obj.list}">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" id="listOutTable">
  <tr>
    <td colspan="2" align="left" valign="middle" class="text_gray2"><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#96bee2">
      <tr>
        <td height="21" background="${baseURL}/images/table_bg.jpg">&nbsp;&nbsp;
        <span class="text_blue_b">
        <img src="${baseURL}/images/008.png" width="16" height="16" align="absmiddle" />&nbsp;商品列表：</span></td>
      </tr>
      <tr>
        <td height="13" valign="top" bgcolor="#FFFFFF">
        <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF" id="listTable">
	<tr align="center" bgcolor="#eeeeee">
		<td height="25" width="5%"><input type="checkbox" onclick="selectAll(this.checked);"></td>
		<td width="5%">商品编号</td>
		<td width="35%">商品名称</td>
		<td width="8%">供货价</td>
		<td width="8%">库存数量</td>
		<td width="8%">销售数量</td>
		<td width="12%">产地信息</td>
		<td width="8%">审核状态</td>
		<td>操作</td>
	</tr>
	<c:forEach var="oneRow" items="${obj.list}">
		<tr align="center">
			<td><input name="chk" type="checkbox" id="chk" value="${oneRow.id}" /></td>
			<td>${oneRow.id}</td>
			<td>${oneRow.productName}</td>
			<td align="right">${oneRow.supplierPrice}</td>
			<td align="right">${oneRow.stockNumber}</td>
			<td align="right">${oneRow.sellNumber}</td>
			<td>${oneRow.productPlace}</td>
			<td><c:if test="${oneRow.passStatus==1}"><font color="lightgreen">通过</font></c:if>
				<c:if test="${oneRow.passStatus!=1}"><font color="red">未审核</font></c:if></td>
			<td>
			<a href="toEditProduct?id=${oneRow.id}">[编辑]</a>
			<a href="#" onclick="delById('${ctx}',${oneRow.id})">[删除]</a>
			</td>
		</tr>
	</c:forEach>
     </table>
      </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="5" colspan="2">
    	<input name="button" type="button" onclick="delByIds('${ctx}');" value="批量删除" class="myButton"></td>
  </tr>
  <tr>
    <td height="1" colspan="2" bgcolor="#A6CAE8"></td>
  </tr>
  <tr>
    <td height="25" colspan="2"><%@ include file="../include/listpage.jsp"%>
    </td>
  </tr>
  <tr>
    <td height="1" colspan="2" bgcolor="#A6CAE8"></td>
  </tr>
</table>
<script src="${ctx}/js/listSupplierProduct.js"></script>
</c:if> --%>

<%@ include file="../include/bottom.jsp"%>